﻿Public Class KeToanNganHang
    Private Function getMa() As String
        'Dim ma As String = Me.HttientoTableAdapter.getMaNganHang(New Date(2012, 4, 1), New Date(2012, 4, 30))
        ''MessageBox.Show(ma)
        'If IsNothing(ma) Then
        '    Return Today.Year & Today.Month & Today.Day
        'Else
        '    Return ma
        'End If
        Return ""
    End Function
    Private Sub KeToanTienMat_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Cursor = Cursors.WaitCursor
        Me.DmnganhangTableAdapter.Fill(Me.ErpharmaDataSet.dmnganhang)
        'Me.KetoannganhangchitietTableAdapter.Fill(Me.ErpharmaDataSet.ketoannganhangchitiet)
        Me.KetoannganhangTableAdapter.Fill(Me.ErpharmaDataSet.ketoannganhang)
        Me.DmtinhtrangTableAdapter.Fill(Me.ErpharmaDataSet.dmtinhtrang)
        Me.DmloaitienTableAdapter.Fill(Me.ErpharmaDataSet.dmloaitien)
        Me.DmtinhtrangphieuTableAdapter.Fill(Me.ErpharmaDataSet.dmtinhtrangphieu)
        Me.DmthoigianTableAdapter.Fill(Me.ErpharmaDataSet.dmthoigian)
        Me.DmnhanvienbanhangTableAdapter.Fill(Me.ErpharmaDataSet.dmnhanvienbanhang)
        Me.DmkhachhangTableAdapter.Fill(Me.ErpharmaDataSet.dmkhachhang)
        Me.DmnghiepvuTableAdapter.Fill(Me.ErpharmaDataSet.dmnghiepvu)
        Me.DmthoigianIUltraCombo.setDataTable(Me.ErpharmaDataSet.dmthoigian) 'iultracombo
        Me.DmloaitienIUltraComBoEditor.setThemUltraGrid(Me.DmloaitienIUltraGrid) 'iultracomboeditor
        Me.DmphongbanTableAdapter1.Fill(Me.ErpharmaDataSet.dmphongban)
        Me.Dmtaikhoancap2TableAdapter.Fill(Me.ErpharmaDataSet.dmtaikhoancap2)
        'set doi tuong cho ultragrid
        Me.KetoantienmatIUltraGrid_DanhSach.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.ketoannganhang, Me.KetoannganhangchitietBindingSource, Me.KetoannganhangTableAdapter, Me.ErpharmaDataSet)
        Me.KetoantienmatIUltraGrid_ThongTin.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.ketoannganhang, Me.KetoannganhangchitietBindingSource, Me.KetoannganhangTableAdapter, Me.ErpharmaDataSet)
        Me.KeToanNganHang_TienTe.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.ketoannganhang, Me.KetoannganhangchitietBindingSource, Me.KetoannganhangTableAdapter, Me.ErpharmaDataSet)
        'Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.ketoannganhangchitiet, Me.FKketoannganhangchitietketoannganhangBindingSource, Me.KetoannganhangchitietTableAdapter, Me.ErpharmaDataSet)
        'Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.ketoannganhangchitiet, Me.FKketoannganhangchitietketoannganhangBindingSource, Me.KetoannganhangchitietTableAdapter, Me.ErpharmaDataSet)
        Me.DmloaitienIUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmloaitien, Me.DmloaitienBindingSource, Me.DmloaitienTableAdapter, Me.ErpharmaDataSet)
        'set giao dien
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setGiaoDienTuyBien()
        Me.KetoantienmatIUltraGrid_ThongTin.setGiaoDien_Doi_ThongTin()
        Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.setGiaoDienTuyBien()
        Me.Ketoantienmatchitiet_ThongTinChinh_TimKiem_IUltraGrid.setGiaoDienTuyBien()
        Me.Ketoantienmatchitiet_ThongTinKhaiThue_TimKiem_IUltraGrid.setGiaoDienTuyBien()
        Me.KetoantienmatIUltraGrid_DanhSach.setGiaoDienTuDong()
        Me.DmthoigianIUltraCombo.setGiaoDien()
        Me.DmnghiepvuIUltraDropDown.setGiaoDien_An_ColumnHeader()
        Me.DmtinhtrangphieuIUltraDropDown.setGiaoDien_An_ColumnHeader()
        Me.DmnhanvienbanhangIUltraDropDown.setGiaoDien()
        Me.DmloaitienIUltraDropDown.setGiaoDien_An_ColumnHeader()
        Me.DmkhachhangIUltraDropDown.setGiaoDien()
        Me.DmloaitienIUltraGrid.setGiaoDienVua()
        Me.DmtinhtrangIUltraDropDown.setGiaoDien()
        'set them ultradropdown
        Me.KetoantienmatIUltraGrid_DanhSach.setThemIUltraDropDown(Me.DmnghiepvuIUltraDropDown, Me.ErpharmaDataSet.dmnghiepvu)
        Me.KetoantienmatIUltraGrid_ThongTin.setThemIUltraDropDown(Me.DmnghiepvuIUltraDropDown, Me.ErpharmaDataSet.dmnghiepvu)
        Me.KetoantienmatIUltraGrid_DanhSach.setThemIUltraDropDown(Me.DmtinhtrangphieuIUltraDropDown, Me.ErpharmaDataSet.dmtinhtrangphieu)
        Me.KetoantienmatIUltraGrid_ThongTin.setThemIUltraDropDown(Me.DmtinhtrangphieuIUltraDropDown, Me.ErpharmaDataSet.dmtinhtrangphieu)
        Me.KetoantienmatIUltraGrid_DanhSach.setThemIUltraDropDown(Me.DmnhanvienbanhangIUltraDropDown, Me.ErpharmaDataSet.dmnhanvienbanhang)
        Me.KetoantienmatIUltraGrid_ThongTin.setThemIUltraDropDown(Me.DmnhanvienbanhangIUltraDropDown, Me.ErpharmaDataSet.dmnhanvienbanhang)
        Me.KetoantienmatIUltraGrid_DanhSach.setThemIUltraDropDown(Me.DmloaitienIUltraDropDown, Me.ErpharmaDataSet.dmloaitien)
        Me.KetoantienmatIUltraGrid_ThongTin.setThemIUltraDropDown(Me.DmloaitienIUltraDropDown, Me.ErpharmaDataSet.dmloaitien)
        Me.KetoantienmatIUltraGrid_DanhSach.setThemIUltraDropDown(Me.DmkhachhangIUltraDropDown, Me.ErpharmaDataSet.dmkhachhang)
        Me.KetoantienmatIUltraGrid_ThongTin.setThemIUltraDropDown(Me.DmphongbanIUltraDropDown, Me.ErpharmaDataSet.dmphongban)
        Me.DmloaitienIUltraGrid.setThemIUltraDropDown(Me.DmtinhtrangIUltraDropDown, Me.ErpharmaDataSet.dmtinhtrang)
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setThemIUltraDropDown(Me.DmkhachhangIUltraDropDown, Me.ErpharmaDataSet.dmkhachhang)
        'set thêm iultracomboeditor
        Me.KetoantienmatIUltraGrid_ThongTin.setUltraComboEditor(Me.DmloaitienIUltraComBoEditor)
        Me.DmloaitienIUltraGrid.setUltraComboEditor(Me.DmloaitienIUltraComBoEditor)
        'set tìm kiếm
        Me.KetoantienmatIUltraGrid_DanhSach.setTimKiemTrenCotUltraGrid()
        Me.Ketoantienmatchitiet_ThongTinChinh_TimKiem_IUltraGrid.setTimKiemTrenCotUltraGrid()
        Me.Ketoantienmatchitiet_ThongTinKhaiThue_TimKiem_IUltraGrid.setTimKiemTrenCotUltraGrid()
        'set giá trị mặt định
        Me.KetoantienmatIUltraGrid_ThongTin.setMacDinh("ma", getMa)
        Me.KetoantienmatIUltraGrid_ThongTin.setMacDinh("tygia", 1)
        Me.KetoantienmatIUltraGrid_ThongTin.setMacDinh("tienvnd", 0)
        Me.KetoantienmatIUltraGrid_ThongTin.setMacDinh("sochungtu", "")
        Me.KetoantienmatIUltraGrid_ThongTin.setMacDinh("ngaylap", Today)
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setMacDinh("ngayhoadon", Today)
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setMacDinh("ngay", Today)
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setMacDinh("phantramthue", 0)
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setMacDinh("thue", 0)
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setMacDinh("doanhthu", 0)
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setMacDinh("tongcong", 0)
        Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.setMacDinh("phantramthue", 0)
        Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.setMacDinh("thue", 0)
        Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.setMacDinh("tongcong", 0)
        'set group by - iultragrid timkiem
        Me.Ketoantienmatchitiet_ThongTinChinh_TimKiem_IUltraGrid.setGroupBy("ma")
        Me.Ketoantienmatchitiet_ThongTinKhaiThue_TimKiem_IUltraGrid.setGroupBy("ma")
        'set menustrip
        Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setChoPhepMenuStrip()
        Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.setChoPhepMenuStrip()
        Me.DmloaitienIUltraGrid.setChoPhepMenuStrip()
        'set focus
        'Me.KetoantienmatIUltraGrid_ThongTin.setFocusCellUltraGridNotNew("tinhtrang", Me.IUltraGrid1)
        'Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid.setFocusIUltraGrid("nguonvon", Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid)
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub btnTaoMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTaoMoi.Click
        Me.KetoantienmatIUltraGrid_ThongTin.setMacDinh("ma", getMa)
        If (Me.KetoantienmatIUltraGrid_ThongTin.getTaoMoi()) Then
        End If
    End Sub

    Private Sub btnLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLuu.Click
        If Me.KetoantienmatIUltraGrid_ThongTin.getLuu() Then
        End If
    End Sub

    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click
        Me.KetoantienmatIUltraGrid_ThongTin.getXoa()
    End Sub

    Private Sub btnLamTuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLamTuoi.Click
        Me.KetoantienmatIUltraGrid_ThongTin.getRefresh()
    End Sub

    Private Sub btnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIn.Click

    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Dispose()
        Me.Close()
    End Sub

    Private Sub Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid_AfterCellActivate(sender As Object, e As System.EventArgs) Handles Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.AfterCellActivate
        'If Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.ActiveRow.Cells("sohoadon").IsActiveCell Then
        '    Me.UltraTabControl2.SelectedTab = Me.UltraTabControl2.Tabs(1)
        'End If
    End Sub

    Private Sub Ketoantienmatchitiet_ThongTinChinh_TimKiem_IUltraGrid_ClickCell(sender As Object, e As Infragistics.Win.UltraWinGrid.ClickCellEventArgs) Handles Ketoantienmatchitiet_ThongTinChinh_TimKiem_IUltraGrid.ClickCell
        If Me.Ketoantienmatchitiet_ThongTinChinh_TimKiem_IUltraGrid.ActiveRow.Index <> -1 Then
            Try
                Me.KetoannganhangBindingSource.Position = Me.KetoannganhangBindingSource.Find("ma", Me.Ketoantienmatchitiet_ThongTinChinh_TimKiem_IUltraGrid.ActiveRow.Cells("ma").Value)
            Catch ex As Exception
            End Try
        End If
    End Sub

    Private Sub KetoantienmatIUltraGrid_ThongTin_BeforeCellDeactivate(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles KetoantienmatIUltraGrid_ThongTin.BeforeCellDeactivate
        If Me.KetoantienmatIUltraGrid_ThongTin.ActiveRow.Cells("tinhtrang").IsActiveCell Then
            Me.KetoantienmatIUltraGrid_ThongTin.getLuuNgam()
            Me.KetoantienmatIUltraGrid_ThongTin.setFocusCellUltraGridNotNew(Me.KeToanNganHang_TienTe)
        End If
    End Sub

    Private Sub IUltraGrid1_BeforeCellDeactivate(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles KeToanNganHang_TienTe.BeforeCellDeactivate
        If Me.KeToanNganHang_TienTe.ActiveRow.Cells("tienvnd").IsActiveCell Then
            'Me.IUltraGrid1.getLuuNgam()
            Me.KeToanNganHang_TienTe.setFocusCellUltraGrid(Me.Ketoantienmatchitiet_ThongTinChinh_IUltraGrid)
        End If
    End Sub

End Class